from appium import webdriver


class Driver:

    def __init__(self, driver):
        self.driver = driver

    def driver(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'  # 测试平台,不能写错
        desired_caps['platformVersion'] = '6.0'  # 平台版本,不能写错
        desired_caps['deviceName'] = 'Producing_Voice'  # 设备名称，其实没有太大的用处，只是给测试程序使用的
        # desired_caps['app'] = r'D:\chrome_dolwon\lemonban_release_v2.1.2_finally.apk'  #apk 文件路径名，如果设备还没有此应用，则会安装。
        desired_caps['appPackage'] = 'com.xxzb.fenwoo'
        desired_caps['appActivity'] = 'com.xxzb.fenwoo.activity.addition.WelcomeActivity'
        # desired_caps['unicodeKeyboard'] = True
        desired_caps['noReset'] = True  # 保证了app 测试前不会清除数据，缺省是会清除数据的，
        desired_caps['newCommandTimeout'] = 6000

        # 启动Remote RPC  与appium server进行连接 并发送
        driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        driver.implicitly_wait(10)


# 1.操作对象在线 == 模拟器还是真机 要能够被adb识别  adb devices
# 2.appium server必须启动 处于监听状态 接收我们python appium客户端的请求
# 3.执行python代码

# 账号密码：'user': "18684720553", 'passwd': "python"

from datetime import datetime

a = "2019-07-04"
date_time = datetime.strptime(a, "%Y-%m-%d")
# print(date_time.date())
# print(type(date_time.date()))


b = datetime.now().date()
# print(b)
# print(type(b))


import requests, pprint

plload = {
    "parameters": {
        "taskId": ""
    }
}

res = requests.get("https://ceshi.icloudcare.com/icare/ecare?"
                   "user_name=vsiyly&"
                   "ticket=58CA7E63B51EE4CB16F07E605FAE1AEC&"
                   "udid=0B9B0593AE0741FD85ABC52DA01C924E&"
                   "cmd=CANCEL_ALERT_TASK&"
                   "payload=%7B%22parameters%22%3A%7B%22"
                   "taskId%22%3A%22%22%7D%7D", params=plload)

# pprint.pprint(res.json())

from selenium import webdriver
# from selenium.webdriver.chrome.options import Options
#
# req_url = "https://www.baidu.com"
# chrome_options = Options()
# # 设置chrome浏览器无界面模式
# chrome_options.add_argument('--headless')
# browser = webdriver.Chrome(chrome_options=chrome_options)
# # 开始请求
# browser.get(req_url)
# # 打印页面源代码
# print(browser.page_source)
# # 关闭浏览器
# browser.close()
# # 关闭chreomedriver进程
# browser.quit()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# 产生1000个4列正态分布的随机数
data = pd.DataFrame(np.random.randn(1000, 4))
# 对其中的数据进行累加，目的是为了能够使例子中显示的曲线有上升波动效果
data = data.cumsum()
# 打印出前几行的数据，方便我们调试其中的数据值
print(data.head())
# 画图表
data.plot()
# 显示图表
plt.show()
